using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
using DG.Tweening;

public class TabTextManger : Singleton<TabTextManger>
{
    // public GameObject tabText;

    private PlayerInput _playerInput;
    public TextMeshProUGUI tabTextField;

    protected override void Awake()
    {
        base.Awake();
        _playerInput = new PlayerInput();

        _playerInput.Gameplay.TabText.started += OnTabText;
        // tabTextField = tabText.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
    }
    
    private void OnEnable()
    {
        _playerInput.Enable();
    }

    private void OnDisable()
    {
        _playerInput.Disable();
    }
    
    private void OnTabText(InputAction.CallbackContext obj)
    {
        if (tabTextField.text != null)
        {
            StartCoroutine(ShowTabText());
        }
    }

    private IEnumerator ShowTabText()
    {
        tabTextField.DOColor(new Color(1, 1, 1, 1), 1);
        yield return new WaitForSeconds(3);
        tabTextField.DOColor(new Color(1, 1, 1, 0), 1);
    }
}
